import matplotlib.pyplot as plt
import numpy as np
from Linac import *

fieldDir = '/home/ainswort/HOMDynamics/LatticeFiles/'

A=CavitySection(cavNum=54,E_in=160e6)
A.loadField(fieldDir+'Efield-map.dat',0.65,19.1e6)
A.IntegrationTrack()
A.VoltageCorrect()

Drifts1 = np.ones(55)*0.5
Drifts2 = np.ones(55)*0.5

P1=Pulse(1,54,1/352.2e6,40e-3)
P2=Pulse(1,54,1/352.2e6,40e-3)

P1.dE[0,0] = 0.1e6
P2.dE[0,0] = 0.1e6


Lin1 = Linac(A,Drifts1,P1)
Lin2 = Linac(A,Drifts2,P2)


Lin2.TrackSlow()
Lin1.Track()

plt.plot(P1.dE.T*1e-6,'-o')
plt.plot(P2.dE.T*1e-6,'-o')


plt.show()



